<script setup>
import { ref, onMounted } from 'vue';

import { getAllCommodityCategoryList } from '@/apis/commodity';

defineProps({
  modelValue: {
    type: String
  }
});
const emit = defineEmits(['update:modelValue']);

const categoryList = ref([]);

onMounted(async () => {
  let res = await getAllCommodityCategoryList();
  categoryList.value = res.data;
});
</script>

<template>
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
  >
    <el-option
      v-for="(item, index) in categoryList"
      :key="index"
      :label="item.categoryName"
      :value="item.id"
    />
  </el-select>
</template>

<style></style>
